package com.fan.shop.businesslogic;

import org.apache.log4j.Logger;

import com.fan.shop.domain.Location;
import com.fan.shop.global.ShopGlobalVariables;
import com.fan.shop.process.ProcExec;
import com.fan.shop.services.LocationService;

public class LocationDeleteProcess extends ProcExec<Integer> {

	private static Logger logger = Logger
			.getLogger(LocationUpdateProcess.class);
	private LocationService locationService;
	private int id;
	private String errorMessage;

	public LocationDeleteProcess() {
		// TODO Auto-generated constructor stub
	}

	public static Logger getLogger() {
		return logger;
	}

	public static void setLogger(Logger logger) {
		LocationDeleteProcess.logger = logger;
	}

	public LocationService getLocationService() {
		return locationService;
	}

	public void setLocationService(LocationService locationService) {
		this.locationService = locationService;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getErrorMessage() {
		return errorMessage;
	}

	public void setErrorMessage(String errorMessage) {
		this.errorMessage = errorMessage;
	}

	@Override
	public Integer processImpl() {
		Location location = locationService.getLocation(id);
		if (location == null) {
			errorMessage = "No Such Location exists!";
			return ShopGlobalVariables.FAILED;
		}

		locationService.deleteLocation(location);
		return ShopGlobalVariables.SUCCESS;
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

}
